﻿using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SmartCard.PcscApi;
using System.Text;
using System.Collections.Generic;

namespace SmartCard.Framework.UnitTests.ApiPlugins.Pcsc
{
	/// <summary>
	/// Tests specific to PCSC.  Most of these tests will require that
	/// a physical PC/SC reader device is connected to the PC
	/// </summary>
	[TestClass]
	public class PcscTests
	{
		/// <summary>
		/// Currently this test runs on my laptop, just to ensure that we can find readers,
		/// I expect two readers with very specific names.  This will vary based on hardware,
		/// 
		/// Tested on an E6510 Dell LATITUDE
		/// </summary>
		[TestMethod]
		public void SmartCardReaderDetection()
		{
			PcscSmartCardReaderDiscoveryProcess discoveryProcess = new PcscSmartCardReaderDiscoveryProcess();

			var readers = discoveryProcess.Discover();

			// ensure we have the broadcom reader.  this is a default PC/SC smart card reader this laptop has.
			Assert.AreEqual(1, readers.Where((x) => x.FriendlyName.StartsWith("Broadcom Corp Contacted SmartCard ")).Count());
		}


		[TestMethod]
		public void PcscDiscoveryTest()
		{
			var discoveryModule = new PcscSmartCardReaderDiscoveryProcess();
			var readers = discoveryModule.Discover();
		}
	}
}
